﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;

namespace Project.Web
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        //public static void RegisterRoutes(RouteCollection routes)
        //{
        //    //routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        //    //routes.IgnoreRoute("*");

        //    //routes.MapRoute(
        //    //    "Default", // Route name
        //    //    "{controller}/{action}/{id}", // URL with parameters
        //    //    new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        //    //);

        //}

        protected void Application_Start()
        {
            // log4net配置信息
            log4net.Config.XmlConfigurator.Configure();

            //ControllerBuilder.Current.SetControllerFactory(typeof(Project.Controllers.SpringControllerFactory));

            //AreaRegistration.RegisterAllAreas();

            //RegisterRoutes(RouteTable.Routes);                     

        }

        protected void Application_Error(object sender, EventArgs e)
        {
            //log4net.ILog logger = log4net.LogManager.GetLogger("Logger");

            //if (Server.GetLastError() != null)
            //{
            //    Exception ex = Server.GetLastError().GetBaseException();
            //    StringBuilder sb = new StringBuilder();
            //    sb.Append(ex.Message);
            //    sb.Append("\r\nSOURCE: " + ex.Source);
            //    sb.Append("\r\nFORM: " + Request.Form.ToString());
            //    sb.Append("\r\nQUERYSTRING: " + Request.QueryString.ToString());
            //    sb.Append("\r\n引发当前异常的原因: " + ex.TargetSite);
            //    sb.Append("\r\n堆栈跟踪: " + ex.StackTrace);
            //    logger.Error(sb.ToString());
            //    Server.ClearError();
            //}
        }

        /// <summary>
        /// 在实现 批量生成 PDF 的时候
        /// “会话状态已创建一个会话ID，但由于响应已被应用程序刷新而无法保存它”
        /// http://topic.csdn.net/u/20080110/17/6235ede4-4fd5-42dc-8920-bfe8762cc692.html
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Session_Start(object sender, EventArgs e)
        {
            string sessionId = Session.SessionID;
        }
    }
}